package com.itheima.fanxing;

import com.itheima.domain.Student;

import java.util.ArrayList;

/**
 * 自定义泛型方法
 */
public class Test05{


    public static void main(String[] args) {
        String s="只因你太美";
       sing(s);
        Student student = new Student("蔡徐坤", 22);
        sing(student);

        ArrayList<String> strings = addElement(new ArrayList<String>(), "蔡徐坤", "吴亦凡");
        System.out.println(strings);
        ArrayList<Student> students1 = new ArrayList<>();
        Student student1 = new Student("鹿晗", 30);
        Student student2 = new Student("谢大脚", 50);
        ArrayList<Student> students = addElement(students1, student1,student2 );
        System.out.println(students);


    }

    //定义方法
    //修饰符  <T> 返回值  方法名  (形参列表){}
    public static <T> void  sing(T t){
        System.out.println("唱一首"+t);
    }
    //定义方法 向集合中添加元素
    //参数 集合<T> 元素1 ,元素2
    //返回值 集合
    public static <T> ArrayList<T> addElement(ArrayList<T> list,T t1,T t2){
        //向集合中添加元素
        list.add(t1);
        list.add(t2);
        return  list;
    }


}
